package cn.ztuo.bitrade.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

/**
 * @author: Xiazt
 * @date: 2020-04-22 15:08
 */
public class NumberUtils {

    public static StringBuilder getLuckyCode(){
        Set<String> set = new TreeSet<String>();
        while (true) {
            int sui = (int) (Math.random() * 33) + 1;// 获取33以内的数字
            set.add(sui < 10 ? "0" + sui : "" + sui);//将元素存入集合中
            if (set.size() == 6) {//存满六个红色球，则结束循环
                break;
            }
        }
        int sui2 = (int) (Math.random() * 16) + 1;// 获取16以内的数字
        String blue = sui2 < 10 ? "0" + sui2 : "" + sui2;

        StringBuilder number = new StringBuilder();
        for (String s : set) {
            number.append(s);
        }
        return number.append(blue);
    }

    public static List<String> split(String number){
        char[] chars = number.toCharArray();
        List<String> strings = new ArrayList<>();
        for (int i = 0; i < chars.length; i += 2) {
            strings.add(chars[i]+"" + chars[i + 1]+"");
        }
        return strings;
    }

}
